package indi.jp.project.core.entity;

public class JsonResult {

    public JsonResult(){
        this.code = 0;
        this.message = "成功";
        this.data = "";
    }

    public JsonResult(int code, String message, Object data){
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static JsonResult success(){
        return new JsonResult(0, "操作成功", null);
    }

    public static JsonResult success(Object data){
        return new JsonResult(0, "成功", data);
    }

    public static JsonResult error(){
        return new JsonResult(-1, "服务暂不可用，请联系管理员", "");
    }

    public static JsonResult error(String message){
        return new JsonResult(-1, message, "");
    }

    public static JsonResult failure(String message){
        return new JsonResult(1, message, "");
    }

    private int code;

    private String message;

    private Object data;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
